﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows;

namespace CountJobTags.CustomControls {
    public class ImprovedButton : Button {
        // Create a custom routed event by first registering a RoutedEventID
        // This event uses the bubbling routing strategy
        public static readonly RoutedEvent TextRemovedEvent = EventManager.RegisterRoutedEvent("TextRemoved", 
                                RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(ImprovedButton));

        // Provide CLR accessors for the event
        public event RoutedEventHandler Tap {
            add { AddHandler(TextRemovedEvent, value); }
            remove { RemoveHandler(TextRemovedEvent, value); }
        }

        // This method raises the Tap event
        void RaiseTextRemovedEvent() {
            RoutedEventArgs newEventArgs = new RoutedEventArgs(ImprovedButton.TextRemovedEvent);
            RaiseEvent(newEventArgs);
        }

        public void ChangeText(string newText) {
            this.Content = newText;
            RaiseTextRemovedEvent();

        }
    }
}
